package com.it.xuehang.mapper;

import com.it.xuehang.entity.ResourceCategory;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Optional;

/**
 * <p>
 * 资源类别。物资，装备，队伍，避难场所，防护目标等 Mapper 接口
 * </p>
 *
 * @author xuehang
 * @since 2024-12-10
 */
public interface ResourceCategoryMapper extends BaseMapper<ResourceCategory> {
   // 查询根据父类别ID查找子类别
    @Select("SELECT * FROM RESOURCE_CATEGORY WHERE RESCATEPARENTID = #{rescateParentId}")
    List<ResourceCategory> findByRescateParentId(@Param("rescateParentId") String rescateParentId);

    // 使用原生SQL查询根据主键ID查找资源类别
    @Select(value = "SELECT * FROM RESOURCE_CATEGORY WHERE RESCATEID = #{rescateId}")
    Optional<ResourceCategory> findById(@Param("rescateId") String rescateId);
}
